<?php

namespace app\queue\stomp;

use app\queue\BaseConsumer;
use support\bootstrap\Log;
use common\service\ChatService;

class CreateChatConsumer extends BaseConsumer
{

    // 要消费的队列名
    public $queue = 'create_chat';

    // 连接名，对应 config/redis_queue.php 里的连接`
    public $connection = 'default';

    /**
     * @param $data
     */
    public function doConsume($data)
    {
        try {
            $chatService = new ChatService();
            $chatService->createChatAndChatUsers($data['chat'], $data['chat_users'], $data['owner']);
        } catch (\Throwable $e) {
            Log::error("##########################");
            Log::error($e->getMessage());
            Log::error($e->getCode());
            Log::error($e->getTraceAsString());
            Log::error("##########################");
        }

    }
}
